export function mono8ToBase64(mono8Data) {
  // 解码数据
  const data = atob(mono8Data.data);
  const bytes = new Uint8Array(data.length);

  for (let i = 0; i < data.length; i++) {
    bytes[i] = data.charCodeAt(i);
  }

  // 创建Canvas对象
  const canvas = document.createElement("canvas");
  canvas.width = mono8Data.width;
  canvas.height = mono8Data.height;

  // 获取Canvas上下文
  const ctx = canvas.getContext("2d");
  const imageData = ctx.createImageData(canvas.width, canvas.height);

  // 设置像素值
  for (let i = 0; i < bytes.length; i++) {
    imageData.data[i * 4] = bytes[i]; // red
    imageData.data[i * 4 + 1] = bytes[i]; // green
    imageData.data[i * 4 + 2] = bytes[i]; // blue
    imageData.data[i * 4 + 3] = 255; // alpha
  }

  // 绘制到Canvas上
  ctx.putImageData(imageData, 0, 0);

  const imgUrl = canvas.toDataURL();
  return imgUrl;
}
